<?
include("includes/functions.php");
$linkID = $_GET[linkID];
$sql = "SELECT * from transLinks WHERE LinkID = '$linkID'";
$result = mysql_db_query($dbname,$sql);
$row = mysql_fetch_assoc($result);
$linkURL   = $row[Link];
$linkTitle = stripslashes($row[Title]);
$linkViews = $row[Views];

// Let's just increment views and redirect
if (empty($rank)) {
	// Increment views
	$newViews = $linkViews+1;
	$sql = "UPDATE transLinks SET Views = '$newViews' WHERE LinkID = '$linkID'";
	$result = mysql_db_query($dbname,$sql);
	
	// Are we dealing with a site document here?
	if (substr($linkURL,0,4) == 'docs') {
		$statusCode = 1;
	} else {	
		// OK but first let's see if this link is even good...
		linkChecker($linkURL);
		//echo 'LinkURL: '.urldecode($linkURL);
		if ($html) { getstatuscode($html); }
	}	
		
	// Parse status
	$statusCode = substr($status,0,4);
	if ( ($statusCode == 400) || ($statusCode == 404) || ($statusCode == 408) ) {
		$siteError = 1;
		header("Location: badLink.php?linkID=$linkID&statusCode=$statusCode");
	} else {
		header("Location: $linkURL");
	}
}	

?>
<!--
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
	<title><?=$linkTitle; ?></title>
	<link rel="STYLESHEET" href="http://www.tcnTransition.org/css/layoutns.css" />
	<style type="text/css">
	html,body{
	width:100%;
	height:100%;
	margin:0px;
	padding:0px;
	}
	</style>
</head>

<body>
<div style="width: 100%; height: 87px; background: url(images/bgPopup.gif) repeat-x;">
	<table style="width: 100%;">
	<tr>
		<td style="width: 220px; text-align: left; padding-left: 5px; vertical-align: top;">
		<h1>Rank this resource</h1>
		Take a moment and give us your thoughts about this resource.</td>
		<td style="width: 220px; text-align: left;">
			<form action="<?=$PHP_SELF; ?>?rank=1" method="POST">
			<input type="hidden" name="linkID" value="<?=$linkID; ?>">
			<input type="hidden" name="linkURL" value="<?=$linkURL; ?>">
			<select name="rankOptions" size="1">
			<option>Resource Rank</option>
			<option></option>
			<option value="10">Definitely a keeper</option>
			<option value="8">It's OK</option>
			<option value="6">I'm neutral</option>
			<option value="4">Not useful to me</option>
			<option value="2">Toss this one</option>
			</select><br>
			<span><textarea name="comments" id="comments" style="width: 200px; height: 50px;" onFocus="this.value='';">Your comments.</textarea></span>
			</td>
		<td><input type="image" src="images/buttonSubmitRank.gif" style="border: none;" alt="Submit Ranking"></form></td>
		<td style="text-align: right; width: "><a href="<?=$linkURL; ?>"><img src="images/buttonRemoveBanner.gif" style="border: none;" alt="Remove this banner"></a> 
		<a href="javascript:self.close();"><img src="images/buttonClose.gif" style="border: none;" alt="Close Window"></a></td>
	</tr>
	</table>
</div>
<iframe id="linkFrame" src="<?=$linkURL; ?>" style="width: 100%; height: 100%; border: none;"></iframe>
</body>
</html>
-->